<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function print(fn) {
            const a = 200
            fn()
        }
        // 函数作为参数被传递
        
        const a = 100

        function fn() {
            console.log(a) // 在定义的地方往上查找，找到外面全局定义的 a 变量，所以是打印 100
        }

        print(fn)
        // 100

    </script>
</body>
</html>